package org.zg.library.service.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.zg.library.dao.BooksDao;
import org.zg.library.dao.impl.BooksDaoImpl;
import org.zg.library.entity.Books;
import org.zg.library.service.BooksService;

import com.sun.org.apache.regexp.internal.recompile;

public class BooksServiceImpl implements BooksService{

	@Override
	public List<Books> selectAllBooks() {
		// TODO Auto-generated method stub
		BooksDao bs = new BooksDaoImpl();
		ResultSet rs = bs.selectBooks();
		List<Books> list = new ArrayList<Books>();
		if(rs!=null) {
			try {
				while(rs.next()) {
					Books books = new Books();
					books.setB_id(rs.getInt(1));
					books.setB_name(rs.getString(2));
					books.setB_writer(rs.getString(3));
					books.setB_pub(rs.getString(4));
					books.setB_sum(rs.getInt(5));
					list.add(books);
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return list;
	}
}
